package com.study.cglib;

import net.sf.cglib.proxy.MethodInterceptor;
import net.sf.cglib.proxy.MethodProxy;

import java.lang.reflect.Method;

public class LogServiceCglib implements MethodInterceptor {
    private Object object;

    public LogServiceCglib(Object object){
        this.object = object;
    }
    @Override
    public Object intercept(Object o, Method method, Object[] objects, MethodProxy methodProxy) throws Throwable {
        System.out.println(method.getName()+",开始执行");
        method.invoke(object,objects);
        System.out.println(method.getName()+",执行成功");
        return null;
    }
}
